<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
	<head>
		<meta charset="utf-8">
		<title>登录页面</title>
		<link rel="stylesheet" href="layui/css/layui.css">
		 <link rel="stylesheet" href="css/main.css" media="all">
		 <link rel="stylesheet" href="css/plugins/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
	</head>
	
	<body class="layui-layout-login">
	<div class="login-bg">
	    <div class="cover"></div>
	</div>
	<div class="login-content" >
	    <h1 class="login-box-title" onclick="addPic()"><i class="fa fa-fw fa-user"></i>登录</h1>
	    <form class="layui-form" action="${pageContext.request.contextPath}/cmfz-admin/login" method="post" onsubmit="checkForm()">
			
	        <div class="layui-form-item">
	            <label class="layui-icon layui-icon-username" for="username"></label>
	            <input class="layui-input" type="text" name="username" id="username" onblur="checkUsername()" placeholder="用户名">
				<span id="usernameMsg"></span>
	        </div>
			
	        <div class="layui-form-item">
	            <label class="layui-icon layui-icon-password" for="password"></label>
	            <input class="layui-input" type="password" name="password" id="password" onblur="checkPassword()" placeholder="密码">
				<span id="passwordMsg"></span>
	        </div>
			
	        <div class="layui-form-item captcha-item">
	            <label class="layui-icon layui-icon-vercode"></label>
	            <input class="layui-input" type="text" name="code" autocomplete="off" onblur="checkCode()" placeholder="验证码">
				<span id="codeMsg"></span>
	            <div onclick="addPic()" >

					<img id="addPic"  class="captcha-img" src="${pageContext.request.contextPath}/cmfz-admin/getCaptcha" />

				</div>
	        </div>
			
	        <button type="submit" class="layui-btn layui-btn-fluid ajax-login"><i class="fa fa-sign-in fa-lg fa-fw"></i> 登录</button>
	    </form>
	</div>
	</body>
	<script src="${pageContext.request.contextPath}/layui/layui.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/js/jquery-1.12.4.js" type="text/javascript"></script>
	<script>
		function addPic() {
			// 修改图片的src属性  在url后拼接随机数
			$("#addPic").prop("src","${pageContext.request.contextPath}/cmfz-admin/getCaptcha?hh="+Math.random());
		}
		function checkUsername() {
			var username = $("input[name=usrname]").val();
			if(username == ""){
				$("#usernameMsg").html("<font color='red'>用户名为空</font>")
				return false;
			}
			return true;
		}
		function checkPassword() {
			var password = $("input[name=password]").val();
			if(password == ""){
				$("#passwordMsg").html("<font color='red'>密码为空</font>")
				return false;
			}
			return true;
		}
		function checkCode() {
			var code = $("input[name=code]").val();
			if(code == ""){
				$("#codeMsg").html("<font color='red'>验证码为空</font>")
				return false;
			}
			return true;
		}
		function checkForm() {
			return checkUsername()&&checkPassword()&&checkCode();
		}
	</script>
</html>
